package com.spzx.user.api.factory;


import com.spzx.common.core.domain.R;
import com.spzx.user.api.RemoteUserBrowseHistoryService;
import com.spzx.user.api.domain.UserBrowseHistory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * ClassName: RemoteUserBrowseHistoryFallbackFactory
 * Package: com.spzx.user.api.factory
 *
 * @Description:
 * @Author: xvyy
 * @Create: 2024/12/25 - 20:35
 * @Version: v1.0
 */
@Component
@Slf4j
public class RemoteUserBrowseHistoryFallbackFactory implements FallbackFactory<RemoteUserBrowseHistoryService> {
    @Override
    public RemoteUserBrowseHistoryService create(Throwable throwable) {
        log.error("浏览历史服务调用失败:{}", throwable.getMessage());

        return new RemoteUserBrowseHistoryService() {
            @Override
            public R<?> saveUserBrowseHistory(UserBrowseHistory userBrowseHistory, String source) {
                return R.fail("浏览历史服务调用失败" + throwable.getMessage());
            }
        };
    }
}
